package com.hnote.hnoteapplication.ui.utils.supermarket;

/**
 * =====================================================
 * 功    能： 价格类
 * 作    者： 加菲猫
 * 邮    箱： pfliu@3box.cc
 * 时    间： 2017/3/24 0024 17:54
 * =====================================================
 */
public class PriceContext {

    private MemberStrategy strategy;

    public PriceContext(int level){

        switch (level){
            case 1:
                this.strategy = new PrimaryMemberStrategy();
                break;
            case 2:
                this.strategy = new IntermediateMemberStrategy();
                break;
            case 3:
                this.strategy = new AdvancedMemberStrategy();
                break;
        }
    }

    /**
     * 计算商品的价格
     */
    public double quote(double shopPrice){
        return this.strategy.calcPrice(shopPrice);
    }


//    /**
//     *  构造函数，实现一种默认的策略
//     */
//    public PriceContext(MemberStrategy strategy){
//        this.strategy = strategy;
//    }
//
//    /**
//     *  修改策略
//     */
//    public void setMemberStrategy(MemberStrategy strategy){
//        this.strategy = strategy;
//    }
//
//    /**
//     * 计算商品的价格
//     */
//    public double quote(double shopPrice){
//        return this.strategy.calcPrice(shopPrice);
//    }
}
